<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,minimum-scale=1,user-scalable=no"/>
    <title>悦章科技机构平台</title>
    <script src="/Public/static/jquery-2.0.3.min.js"></script>
    <script src="/Public/static/layer/layer.js"></script>
    <!--内容样式-->
    <link rel="stylesheet" href="__PUBLIC__/Home/css/style.css" />
    <link rel="stylesheet" href="__PUBLIC__/Home/css/page.css" />

</head>
<body>

<div class="main">
    <!--  头部  -->
    <include file="menu" />

    <!--  右侧内容  -->
    <div class="content">
        <div class= "ct-title">
            <div class="ctt-bt">线索列表</div>
            <div class="ctt-r">
                <form class="cttr-bd" action="{:U('Home/Index/clueList')}" method="post">
                    <input type="text" placeholder="请输入线索名称或手机号" class="cttrb-wb" name="keyword" value="{$keyword}">
                    <select class="cttrb-xl" name="status">
                        <option value="">线索状态</option>
                        <option value="1" <if condition="$status eq 1">selected</if>>无效数据</option>
                        <option value="2" <if condition="$status eq 2">selected</if>>联系不上</option>
                        <option value="3" <if condition="$status eq 3">selected</if>>挖掘阶段</option>
                        <option value="4" <if condition="$status eq 4">selected</if>>联系方式有效</option>
                        <option value="5" <if condition="$status eq 5">selected</if>>已转客户</option>
                    </select>
                    <select class="cttrb-xl" name="source">
                        <option value="">来源</option>
                        <option value="1" <if condition="$source eq 1">selected</if>>线上咨询</option>
                        <option value="2" <if condition="$source eq 2">selected</if>>客户介绍</option>
                        <option value="3" <if condition="$source eq 3">selected</if>>学生介绍</option>
                        <option value="4" <if condition="$source eq 4">selected</if>>线下联系</option>
                        <option value="5" <if condition="$source eq 5">selected</if>>其他</option>
                    </select>
                    <button class="cttrb-cx">查询</button>
                    <div class="cttrb-fp" onClick="document.getElementById('tck-zdfp').style.display='block'">线索分配设置</div>
                    <a href="{:U('Home/Index/addClue')}" class="cttrb-xz">新增线索</a>
                    <div class="divclear"></div>
                </form>
                <div class="divclear"></div>
            </div>
            <div class="divclear"></div>
        </div>

        <div class="ct-table">
            <table width="100%" border="0">
                <tbody>
                <tr>
                    <th scope="col" width="10%" style="border-top-left-radius: 10px;">线索名称</th>
                    <th scope="col" width="7%">手机号</th>
                    <th scope="col" width="7%">线索状态</th>
                    <th scope="col" width="7%">线索来源</th>
                    <th scope="col" width="7%">添加时间</th>
                    <th scope="col" width="26%">最新跟进记录</th>
                    <th scope="col" width="7%">负责人</th>
                    <!-- <th scope="col" width="9%">被查看记录</th> -->
                    <th scope="col" width="20%" style="border-top-right-radius: 10px;">操作</th>
                </tr>
                <volist name="_list" id="vo">
                    <tr>
                        <td>{$vo.name}</td>
                        <td>{$vo.mobile}</td>
                        <td><if condition="$vo['status'] eq 1">无效数据<elseif condition="$vo['status'] eq 2"/>联系不上<elseif condition="$vo['status'] eq 3"/>挖掘阶段<elseif condition="$vo['status'] eq 4"/>联系方式有效<else/>已转客户</if></td>
                        <td><if condition="$vo['source'] eq 1">线上咨询<elseif condition="$vo['source'] eq 2"/>客户介绍<elseif condition="$vo['source'] eq 3"/>学生介绍<elseif condition="$vo['source'] eq 4"/>线下联系<else/>其他</if></td>
                        <td>{$vo.create_time|date='Y-m-d',###}</td>
                        <td>{$vo.last_content}</td>
                        <td>{$vo.name}</td>
                        <!-- <td><a onClick="document.getElementById('tck-ckjl').style.display='block'">{$vo.this_see}/{$vo.see}</a></td> -->
                        <td><!--<a href="招生系统-线索列表-新增线索.html">编辑</a>-->
                            <a href="{:U('Home/Index/clueDetails',array('id'=>$vo['id']))}">详情</a>
                            <a onclick="show_tck_fpxs('{$vo.id}')">分配线索</a>
                            <a href="{:U('Home/Index/addFollowUp',array('cid'=>$vo['id'],'type'=>2))}">添加跟进</a>
                            <a href="{:U('Home/Index/delClue',array('id'=>$vo['id']))}">删除</a>
                        </td>
                    </tr>
                </volist>
                </tbody>
            </table>
        </div>

        <div class="page">
            {$_page}
        </div>
        <!--<div class="ct-btn">-->
            <!--<div class="ctb-an"><</div>-->
            <!--<div class="ctb-an ctb-an-on">1</div>-->
            <!--<div class="ctb-an">2</div>-->
            <!--<div class="ctb-an">3</div>-->
            <!--<div class="ctb-an">></div>-->
            <!--<div class="divclear"></div>-->
        <!--</div>-->

    </div>

</div>

<!-- 被查看记录 弹出框-->
<div class="tck-demo" id="tck-ckjl">

    <div class="tk-box">
        <div class="tkb-title">
            <div class="tkbt-bt">被查看记录</div>
            <div class="tkbt-close" onClick="document.getElementById('tck-ckjl').style.display='none'">
                <img src="images/icon_delete.png" />
            </div>
            <div class="divclear"></div>
        </div>
        <table width="100%" border="0" class="tkb-table">
            <tbody>
            <tr>
                <th scope="col" width="40%">查看人</th>
                <th scope="col" width="30%">ip</th>
                <th scope="col" width="30%">查看时间</th>
            </tr>
            <tr>
                <td>周柏然</td>
                <td>192.168.100.255</td>
                <td>2020.12.30 12:00</td>
            </tr>
            <tr>
                <td>周柏然</td>
                <td>192.168.100.255</td>
                <td>2020.12.30 12:00</td>
            </tr>
            <tr>
                <td>周柏然</td>
                <td>192.168.100.255</td>
                <td>2020.12.30 12:00</td>
            </tr>
            <tr>
                <td>周柏然</td>
                <td>192.168.100.255</td>
                <td>2020.12.30 12:00</td>
            </tr>
            <tr>
                <td>周柏然</td>
                <td>192.168.100.255</td>
                <td>2020.12.30 12:00</td>
            </tr>
            <tr>
                <td>周柏然</td>
                <td>192.168.100.255</td>
                <td>2020.12.30 12:00</td>
            </tr>
            </tbody>
        </table>
        <div class="tkb-btn">
            <div class="tkbb-an"><</div>
            <div class="tkbb-an tkbb-an-on">1</div>
            <div class="tkbb-an">2</div>
            <div class="tkbb-an">3</div>
            <div class="tkbb-an">></div>
            <div class="divclear"></div>
        </div>
    </div>

</div>



<!-- 分配线索 弹出框-->
<div class="tck-demo" id="tck-fpxs">

    <div class="tk-box">
        <div class="tkb-title">
            <div class="tkbt-bt">分配线索</div>
            <div class="tkbt-close" onClick="document.getElementById('tck-fpxs').style.display='none'">
                <img src="__PUBLIC__/Home/images/icon_delete.png" />
            </div>
            <div class="divclear"></div>
        </div>
        <div class="tkb-fpxs">
            <form class="tkbf-top">
                <input type="text" class="tkbft-wb search_mobile" placeholder="输入姓名或手机号">
                <a class="tkbft-ss" onclick="searchClient()">搜索</a>
                <div class="divclear"></div>
            </form>
            <div class="tkbf-nr">
                <input type="hidden" name="xs_id" value=""/>
                <volist name="teach" id="vo">
                    <label class="tkbfn-box">
                        <span>{$vo.username} / {$vo.mobile}</span>
                        <input type="radio" name="distributor_id" value="{$vo.id}">
                    </label>
                </volist>
                <div class="divclear"></div>
            </div>
        </div>
        <div class="tkb-qr" onclick="distribution()">确定分配</div>
    </div>

</div>

<!-- 线索自动分配设置 弹出框-->
<div class="tck-demo" id="tck-zdfp">

    <div class="tk-box" style="width: 400px;height: 350px;">
        <div class="tkb-title">
            <div class="tkbt-bt">线索自动分配设置</div>
            <div class="tkbt-close" onClick="document.getElementById('tck-zdfp').style.display='none'">
                <img src="__PUBLIC__/Home/images/icon_delete.png" />
            </div>
            <div class="divclear"></div>
        </div>
        <div class="tkb-zdfp">
            <div class="tkbz-box">
                <input type="text" placeholder="分配给多少人" class="tkbzb-l" name="people">
                <div class="tkbzb-r">人</div>
                <div class="divclear"></div>
            </div>
            <div class="tkbz-box">
                <input type="text" placeholder="每人分配条数" class="tkbzb-l" name="number">
                <div class="tkbzb-r">条</div>
                <div class="divclear"></div>
            </div>
            <div class="tkbz-box">
                <select name="type">
                    <option value="">选择分配方式</option>
                    <option value="1">按员工顺序依次分配</option>
                    <option value="2">按员工手头客户数量从少到多分配</option>
                </select>
            </div>
        </div>
        <div class="tkb-qr qd">确定分配</div>
    </div>

</div>

</body>
<script type="text/javascript">
    function show_tck_fpxs(id){
        $("input[name='xs_id']").val(id);
        $("#tck-fpxs").show();
    }

    var label_node = '';
    /**
     * 搜索可分配老师
     * */
    function searchClient()
    {
        var mobile = $('.search_mobile').val();
        if(label_node == ''){
            label_node = $('.tkbf-nr').html();
        }else{
            $('.tkbf-nr').html(label_node)
        }

        var labels = $('.tkbf-nr > label');
        labels.each(function (index, val){
            var label_html = $(val).html();
            if(label_html.indexOf(mobile) == -1) {
                //没有搜索到，移除
                $(val).remove();
            }
        });
    }

    //确定分配
    function distribution()
    {
        var id = $("input[name='xs_id']").val();
        var distributor_id = $("input[name='distributor_id']:checked").val();
        var url = "{:U('Home/Index/distribution')}";
        //console.log(id+"--"+distributor_id);
        $.ajax({
            type: "POST", //类型get，post
            url: url, //链接地址
            data:{"id":id,"distributor_id":distributor_id},//参数，一般post用
            success: function(data){
                var dataObj = JSON.parse(data);
                //成功后函数
                if(dataObj.result == 1){
                    layer.msg(dataObj.msg);
                    setTimeout(function (){
                        window.location.href = "{:U('Home/Index/clueList')}";
                    },1000);
                }else{
                    layer.msg(dataObj.msg);
                }
            },
            error:function(){
                //失败时函数
                layer.msg("失败");
            }
        })
    }

    //确定线索自动分配
    $(".qd").click(function(){
        var type=$("select[name='type']").find('option:selected').val();
        // alert(type);
        if(!type){
            alert('请选择分配方式');return false;
        }
        var people=$("input[name='people']").val();
        var number=$("input[name='number']").val();
        $.ajax({
            url:"{:U('Index/automatic_allocation')}",
            data:{type:type,people:people,number:number},
            type:"POST",
            dataType:"JSON",
            success:function(data){
                alert('分配成功');
                window.location.href = "{:U('Home/Index/clueList')}";
            }
        })
    })
</script>
</html>
